package org.ruanjj.longestSubstring;

import java.util.HashSet;

public class Solution {
    public int lengthOfLongestSubstring(String s) {
        int maxLength = 0;
        for(int i = 0; i < s.length(); i++){
            HashSet<Character> tempSet = new HashSet<>();
            int j = i;
            while(j < s.length() && !tempSet.contains(s.charAt(j))){
                tempSet.add(s.charAt(j));
                j++;
            }
            if(tempSet.size() > maxLength)
                maxLength = tempSet.size();
        }
        return maxLength;
    }
}
